function InitialClick() {
    document.getElementById("InitialButton").style.display = "none";
    document.getElementById("InitialButton1").style.display = "block";
    document.getElementById("InitialButton2").style.display = "block";
    document.getElementById("InitialButton4").style.display = "block";
}
function ShowInitialClick() {
    document.getElementById("InitialButton").style.display = "block";
    document.getElementById("InitialButton1").style.display = "none";
    document.getElementById("InitialButton2").style.display = "none";
    document.getElementById("InitialButton4").style.display = "none";
}
function AnswerClick() {
    document.getElementById("InitialButton").style.display = "none";
    document.getElementById("InitialButton1").style.display = "block";
    document.getElementById("InitialButton2").style.display = "block";
    document.getElementById("InitialButton3").style.display = "block";
    document.getElementById("InitialButton4").style.display = "block";
}
function ShowAnswerClick() {
    document.getElementById("InitialButton").style.display = "block";
    document.getElementById("InitialButton1").style.display = "none";
    document.getElementById("InitialButton2").style.display = "none";
    document.getElementById("InitialButton3").style.display = "none";
    document.getElementById("InitialButton4").style.display = "none";
}
function ImgAudioClick() {
    document.getElementById("audioBody").play();
    const audio = document.getElementById("audioBody");
    audio.addEventListener("ended", () => {
    document.getElementById("audioBodyInfoOne").play();
    });
}
function ImgAudioClickAnswer() {
    document.getElementById("audioBody").play();
}
function ResetClick() {
    history.go(0);
}
//提示
function TipsClick() {
    document.getElementById("floatingImage1").style.display = "block";
    setTimeout(() => {
        document.getElementById("floatingImage1").style.display = "none";
    }, 2000);
}
//返回首页
function close_win() {
    // 停止页面中所有的<audio>播放
    document.querySelectorAll("audio").forEach((audio) => audio.pause());
    currentTimestamp = Date.now();
    operationName = "end";
    additionalInfo = "out";
    CommonNetWork();
    api.openWin({
        name: "AuditoryExpressionSelect",
        url: "./AuditoryRecognitionSelect.html",
        pageParam: {
            uid: userid,
            token: token,
        },
        reload: true,
    });
}
function close_win1() {
    api.openWin({
        name: "SubsetMenu-Basics",
        url: "../../SubsetMenu-Basics.html",
        pageParam: {
            uid: userid,
            token: token,
        },
        reload: true,
    });
}

// function close_win(){
//     // // 停止页面中所有的<audio>播放
//     // document.querySelectorAll("audio").forEach((audio) => audio.pause());
//     // currentTimestamp = Date.now();
//     // operationName = "end";
//     // additionalInfo = "out";
//     // CommonNetWork();
//     api.openWin({
//         name: "SubsetMenu-Basics",
//         url: "../../SubsetMenu-Basics.html",
//         reload: true,
//     });
// }
//点击图片播放
//播放按钮
function ClickAuditory(index) {
    NewAuditoryPlay(index);
}
function NewAuditoryPlay(index) {
    const audioIds = [
        "audioBodyInfoOne",
        "audioBodyInfoTwo",
        "audioBodyInfoThree",
        "audioBodyInfoFour"
    ];
    audioIds.forEach((id, i) => {
        const audio = document.getElementById(id);
        if (i === index - 1) {
            audio.play();
        } else {
            audio.pause();
        }
    });
}
//答对和答错
function hideRightPopup() {
    document.getElementById("backdrop_bgright").style.display = "none";
}
function hideMistake() {
    document.getElementById("backdropMistake").style.display = "none";
}
function AuditoryClickSelect(obj) {
    obj.classList.add("highlighted");
    obj.onclick = null;
    if (obj.dataset.name == "right") {
        document.getElementById("audioBodyRight").play();
        document.getElementById("backdrop_bgright").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdrop_bgright").style.display = "none";
        }, 5000);
        document.getElementById("ImageError").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "correct";
        CommonNetWork();
    } else if (obj.dataset.name == "error") {
        document.getElementById("backdropMistake").style.display = "block";
        document.getElementById("audioBodyMistake").play();
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    }
}
function ClickSelect4(obj) {
    obj.classList.add("highlighted");
    obj.onclick = null;
    if (obj.dataset.name == "right") {
        document.getElementById("audioBodyRight").style.display = "none";
        document.getElementById("audioBodyRight").play();
        document.getElementById("backdrop_bgright").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdrop_bgright").style.display = "none";
        }, 5000);
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        document.getElementById("ImageError3").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "correct";
        CommonNetWork();
    } else if (obj.dataset.name == "error1") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        document.getElementById("ImageError3").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "error2") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageError3").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "error3") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "other") {
        obj.onclick = null;
        obj.classList.remove("highlighted");
    }
}
function ClickSelect3(obj) {
    obj.classList.add("highlighted");
    obj.onclick = null;
    if (obj.dataset.name == "right") {
        document.getElementById("audioBodyRight").style.display = "none";
        document.getElementById("audioBodyRight").play();
        document.getElementById("backdrop_bgright").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdrop_bgright").style.display = "none";
        }, 5000);
        document.getElementById("ImageError2").onclick = null;
        document.getElementById("ImageError1").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "correct";
        CommonNetWork();
    } else if (obj.dataset.name == "error1") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageError2").onclick = null;
        document.getElementById("ImageRight").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "error2") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageRight").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "other") {
        obj.onclick = null;
        obj.classList.remove("highlighted");
    }
}
